﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="NewsList.aspx.cs" Inherits="SGDemo.Web.OA.NewsList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphHead" runat="server">
    <script type="text/javascript">
        var doSelectOrUnselectAll = function (s, e) {
            gvwList.SelectAllRowsOnPage(s.GetChecked());
        }

        var doSelectionChanged = function (s, e) {
            var count = s.GetSelectedRowCount();
            if (count == 1) {
                menuBar.GetItemByName('btnEdit').SetEnabled(true);
                menuBar.GetItemByName('btnView').SetEnabled(true);
            } else {
                menuBar.GetItemByName('btnEdit').SetEnabled(false);
                menuBar.GetItemByName('btnView').SetEnabled(false);
            }
        }

        var doSearch = function () {
            alert(gvwList.GetHeight());
        }

        var doReset = function () {

        }

        var doRowDblClick = function (s, e) {
            var keyid = s.GetRowKey(e.visibleIndex);
            //构造导航URL 
            var url = 'Views/OA/Common/NewsItem.aspx'
            url += '?State=View&Keyid=' + keyid;
            //打开新的选项卡页面
            parent.navTab.openTab(url, url, { title: '新闻明细', fresh: false, external: true, data: {} });
        }

        var doSelectNoticeObject = function () {
            Shadowbox.open({
                content: '../../../Views/OA/Popup/SelectDept.aspx',
                player: 'iframe',
                title: '挑选部门',
                height: 400,
                width: 720
            });
        }

        var doEdit = function () {
//            var count = gvwList.GetSelectedRowCount();
//            if (count < 1) {
//                $.messager.show({
//                    title: '信息提示',
//                    msg: '请选择一条记录！',
//                    showType: 'slide'
//                });
//            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphBody" runat="server">
    <div class="ui-wrapper">
        <div class="ui-menu">
            <uc:MenuDemo ID="menuContent" runat="server" DataFile="../Views/OA/Menu/NewsList.xml" PageCode="RoleItem" />
        </div>
        <div class="ui-content">
            <div class="ui-container">
                <dx:ASPxRoundPanel ID="rpSearch" runat="server" Width="100%" HeaderText="查找条件"
                    CssClass="ui-roundpanel" ContentPaddings-PaddingBottom="5" EnableViewState="false">
                    <PanelCollection>
                        <dx:PanelContent>
                            <ul class="row">
                                <li>
                                    <label>
                                        标题：</label>
                                </li>
                                <li>
                                    <dx:ASPxTextBox ID="txtTitle" runat="server" Width="100%" Height="23">
                                    </dx:ASPxTextBox>
                                </li>
                                <li>
                                    <label>
                                        公告对象：</label>
                                </li>
                                <li>
                                    <ul>
                                        <li>
                                            <dx:ASPxTextBox ID="txtNoticeObject" runat="server" Width="100%"  Height="23">
                                            </dx:ASPxTextBox>
                                        </li>
                                        <li><a href="javascript:doSelectNoticeObject()"></a></li>
                                    </ul>
                                </li>
                                <li>
                                    <label>
                                        发布人：</label>
                                </li>
                                <li>
                                    <dx:ASPxTextBox ID="txtPublisher" runat="server" Width="100%"  Height="23">
                                    </dx:ASPxTextBox>
                                </li>
                                <li>
                                    <label>
                                        发布部门：</label>
                                </li>
                                <li>
                                    <dx:ASPxTextBox ID="txtResponsibility" runat="server" Width="100%"  Height="23">
                                    </dx:ASPxTextBox>
                                </li>
                            </ul>
                            <ul class="row">
                                <li>
                                    <label>
                                        发布日期：</label>
                                </li>
                                <li>
                                    <dx:ASPxDateEdit ID="dePublishDate" runat="server" Width="100%" Height="23"></dx:ASPxDateEdit>
                                </li>
                                <li>
                                    <label>
                                        过期日期：</label>
                                </li>
                                <li>
                                    <dx:ASPxDateEdit ID="deExpireDate" runat="server" Width="100%" Height="23"></dx:ASPxDateEdit>
                                </li>
                                <li>
                                    <label>
                                        状态：</label>
                                </li>
                                <li>
                                    <dx:ASPxComboBox ID="cbState" runat="server" Width="100%" Height="23">
                                          <Items>
                                            <dx:ListEditItem Text="普通" Value="01" />
                                            <dx:ListEditItem Text="重要" Value="02" />
                                            <dx:ListEditItem Text="紧急" Value="03"  />
                                        </Items>
                                    </dx:ASPxComboBox>
                                </li>
                                <li>
                                </li>
                                <li>
                                </li>
                            </ul>
                            <ul class="sl-floatcenter">
                                <li class="sl-floatcenter-item">
                                    <dx:ASPxButton ID="btnSubmit" ClientInstanceName="btnSubmit" runat="server" Text="查 询"
                                        AutoPostBack="false">
                                        <ClientSideEvents Click="doSearch" />
                                    </dx:ASPxButton>
                                </li>
                                <li class="sl-floatcenter-item">
                                    <dx:ASPxButton ID="btnReset" ClientInstanceName="btnReset" runat="server" Text="重 置"
                                        AutoPostBack="false">
                                        <ClientSideEvents Click="doReset" />
                                    </dx:ASPxButton>
                                </li>
                            </ul>
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxRoundPanel>
                <dx:ASPxRoundPanel ID="rpList" runat="server" Width="100%" HeaderText="新闻列表"
                    CssClass="ui-roundpanel" ContentPaddings-PaddingBottom="5" EnableViewState="false">
                    <PanelCollection>
                        <dx:PanelContent>
                            <dx:ASPxGridView ID="gvwList" ClientInstanceName="gvwList" runat="server" AutoGenerateColumns="False"
                                DataSourceForceStandardPaging="True" Width="100%" KeyFieldName="Keyid" DataSourceID="odsList"
                                OnCustomCallback="gvwList_CustomCallback">
                                <Columns>
                                    <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" HeaderStyle-HorizontalAlign="Center"
                                        Width="50">
                                        <HeaderTemplate>
                                            <dx:ASPxCheckBox ID="cbSelectAll" runat="server">
                                                <ClientSideEvents CheckedChanged="doSelectOrUnselectAll" />
                                            </dx:ASPxCheckBox>
                                        </HeaderTemplate>
                                    </dx:GridViewCommandColumn>
                                    <dx:GridViewDataColumn Caption="标题" FieldName="Title" VisibleIndex="1" Width="400">
                                    </dx:GridViewDataColumn>
                                    <dx:GridViewDataColumn Caption="公告对象" FieldName="NoticeObject" VisibleIndex="2" >
                                    </dx:GridViewDataColumn>
                                    <dx:GridViewDataColumn Caption="发布人" FieldName="Publisher" VisibleIndex="3" Width="120">
                                    </dx:GridViewDataColumn>
                                    <dx:GridViewDataDateColumn Caption="发布日期" FieldName="PublishDate" VisibleIndex="4" Width="120">
                                       <PropertiesDateEdit DisplayFormatString="yyyy-MM-dd HH:mm"></PropertiesDateEdit>
                                    </dx:GridViewDataDateColumn>
                                    <dx:GridViewDataColumn Caption="过期日期" FieldName="ExpireDate" VisibleIndex="5" Width="120">
                                    </dx:GridViewDataColumn>
                                    <dx:GridViewDataColumn Caption="状态" FieldName="StateName" VisibleIndex="6" Width="120">
                                    </dx:GridViewDataColumn>
                                </Columns>
                                <ClientSideEvents SelectionChanged="doSelectionChanged" RowDblClick="doRowDblClick" />
                                <SettingsBehavior AllowFocusedRow="true" ColumnResizeMode="Control" ConfirmDelete="true" />
                                <SettingsLoadingPanel Text="加载中..." />
                                <SettingsPager PageSize="10" Mode="ShowPager" Summary-Text="当前第{0}页，共{1}页(共{2}条)">
                                </SettingsPager>
                                <SettingsText EmptyDataRow="没有数据显示" />
                                <Styles>
                                    <AlternatingRow Enabled="True" />
                                </Styles>
                            </dx:ASPxGridView>
                            <%--数据源控件--%>
                            <asp:ObjectDataSource ID="odsList" runat="server" SortParameterName="sortColumns"
                                EnablePaging="true" StartRowIndexParameterName="startRecord" MaximumRowsParameterName="maxRecords"
                                TypeName="SGDemo.Web.OA.NewsList" SelectMethod="News_PagingGet" SelectCountMethod="News_PagingGetCount">
                                <SelectParameters>
                                    <asp:ControlParameter Name="filterConditions" Type="String" ControlID="hfFilterCondition"
                                        PropertyName="Value" ConvertEmptyStringToNull="false" />
                                </SelectParameters>
                            </asp:ObjectDataSource>
                            <%--存储过滤条件--%>
                            <asp:HiddenField ID="hfFilterCondition" ClientIDMode="Static" runat="server" Value=" " />
                        </dx:PanelContent>
                    </PanelCollection>
                </dx:ASPxRoundPanel>
            </div>
        </div>
    </div>
</asp:Content>
